import { http } from "@/utils/request.js";

import api from "@/config/api.js";

/**
 * 通过短信重置密码
 * @param  mobile
 */
export function resetByMobile(params) {
    return http.request({
        url: `/members/resetByMobile`,
        method: "POST",
        params,
    });
}

/**
 * 发送验证码
 * @param  mobile
 */
export function sendMobile(mobile) {
    return http.request({
        url: `${api.common}/common/sms/LOGIN/${mobile}`,
        method: "GET",
    });
}

/**
 * 短信登录
 * @param  mobile
 * @param  code
 */
export function smsLogin(params, clientType) {
    return http.request({
        url: `${api.buyer}/passport/member/smsLogin`,
        method: "POST",
        params,
        /* header: {
            "content-type": "application/x-www-form-urlencoded",
            clientType: clientType,
        }, */
    });
}

/**
 * 修改密码
 * @param  newPassword
 * @param  password
 */

export function modifyPass(params) {
    return http.request({
        url: `/members/modifyPass`,
        method: "PUT",
        params,
    });
}

/**
 * 刷新token
 */
export function refreshTokenFn(refresh_token) {
    return http.request({
        url: `/passport/member/refresh/${refresh_token}`,
        method: "GET",
    });
}